<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环遍历</title>
</head>
<body>
<div>

    <table border="1">
        <tr>
            <td>照片</td>
            <td><img :src="user.pic" alt=""></td>
        </tr>
        <tr>
            <td>姓名</td>
            <td>{{user.name}}</td>
        </tr>
        <tr>
            <td>年级</td>
            <td>{{user.age}}</td>
        </tr>
        <tr>
            <td>爱好:</td>
            <td>
                <ul>
                    <li v-for="item in user.hobby">{{item}}</li>
                </ul>
            </td>
        </tr>
    </table>
    <input type="button" value="添加" @click="f()">
</div>
<!--引入vue-->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            user:{name:"",age:"",pic:"",hobby:"[]"}
        },
        methods:{
            f(){

                let user = {name:"黄涛",age: 18,
                    pic: "tp.jpg",hobby: ["姜可","学习"]};
                v.user = user;
            }
        }

    })
</script>

</body>
</html>
